package com.leadership.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.leadership.entity.LearningMapStudent;
import com.leadership.entity.idm.IdmUser;
import com.leadership.entity.idm.Organization;

/**
 * @author xiaoHU
 *
 */
@Dao("hibernate")
public interface IdmUserDao {

    /**
     * @return
     */
    @Query("FROM IdmUser WHERE mail IS NOT NULL AND parentOrgnofullpath IS NOT NULL")
    public List<IdmUser> listAllIdmUser();

    /**
     * 
     * @param mail
     * @return
     */
    @Query("FROM IdmUser WHERE mail = :mail")
    public IdmUser load(@Variable("mail") String mail);

    /**
     * 
     * @param orgnofullpath
     * @return
     */
    @Query("FROM Organization WHERE orgnofullpath = :orgnofullpath")
    public Organization loadOrganization(@Variable("orgnofullpath") String orgnofullpath);

    /**
     * 
     * @param number
     * @return
     */
    @Query("FROM IdmUser WHERE usernumber = :number")
    public IdmUser loadByNumber(@Variable("number") String number);

    /**
     * 
     * @param date
     * @return
     */
    @Query("FROM IdmUser WHERE joinsysdate >= :date")
    public List<IdmUser> lisyUserByDate(@Variable("date") String date);
    
    @Query("FROM IdmUser WHERE joinsysdate >= :date and usertype is not null and z9121znt is not null")
    public List<IdmUser> lisyAlivaleUserByDate(@Variable("date") String date);
    
    /**
     * 
     * @param email
     * @param id
     * @return
     */
    @Query("FROM LearningMapStudent WHERE disabled = false and email = :email and learningMap.id = :id")
    public LearningMapStudent load(@Variable("email") String email, @Variable("id") Long id);

    /**
     * 
     * @param emails
     * @param id
     * @return
     */
    @Query("FROM LearningMapStudent WHERE disabled = false and email in(:emails) and learningMap.id = :id")
    public List<LearningMapStudent> list(@Variable("emails") List<String> emails, @Variable("id") Long id);
}
